package com.liandu.common;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Page;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PageInfo {
    private Integer pageNum,pageSize;
    private Long totalSize;
    private Object content;

    public static PageInfo of(Page page){
        return new PageInfo(page.getNumber()+1,page.getSize(),page.getTotalElements(),page.getContent());
    }

    public static PageInfo of(Page page, JSON json){
        return new PageInfo(page.getNumber()+1,page.getSize(),page.getTotalElements(),json);
    }
}
